﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ThietBiSo.LinQDB;


namespace ThietBiSo.Models
{
    public class MAdmin
    {
        private _24hmuaonlineDataContext context = new _24hmuaonlineDataContext();
        public List<Admin> FindAll()
        {
            var v = from f in context.Admins select f;

            return v.ToList();
        }
        public Admin login(string username, string password)
        {
            try
            {
                var user = FindAll().Where(d => d.Username.Equals(username) && d.Password.Equals(password)).SingleOrDefault();

                return (Admin)user;
            }
            catch (Exception e)
            {
                e.ToString();
            }
            return null;
        }
        public Admin getUserById(int id)
        {
            return context.Admins.SingleOrDefault(d => d.MaAdmin == id);
        }
        public void SaveChange()
        {
            context.SubmitChanges();
        }
       
    }
}